package com.urms.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.urms.entity.Menu;
import com.urms.entity.QueryMenuCondition;
import com.urms.mapper.MenuMapper;
import com.urms.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MenuServiceImpl implements MenuService {
    @Autowired
    private MenuMapper menuMapper;


    @Override
    public Integer updateMenu(Menu menu) {
        return menuMapper.updateMenu(menu);
    }

    @Override
    public String findMenuNameById(Integer menuParentId) {
        return menuMapper.findMenuNameById(menuParentId);
    }

    @Override
    public Integer deleteMenuById(Integer menuId) {
        return menuMapper.deleteMenuById(menuId);
    }

    @Override
    public PageInfo<Menu> selectMenu(QueryMenuCondition qmc) {
        PageHelper.startPage(qmc.getPageNum(),qmc.getPageSize());
        List<Menu> menuList=menuMapper.selectMenu(qmc);
        PageInfo<Menu> pageInfo=new PageInfo<>(menuList);
        return pageInfo;
    }

    @Override
    public Integer insertMenu(Menu menu) {
        return menuMapper.insertMenu(menu);
    }

    @Override
    public List<Menu> getAllMenu() {
        return menuMapper.menuList();
    }

    @Override
    public PageInfo<Menu> menuList(QueryMenuCondition qmc) {
        PageHelper.startPage(qmc.getPageNum(),qmc.getPageSize());
        List<Menu> menuList= menuMapper.selectMenu(qmc);
        PageInfo<Menu> pageInfo=new PageInfo<>(menuList);
        return pageInfo;
    }

    @Override
    public Integer deleteMenuList(Integer[] menuIds) {
        return menuMapper.deleteMenuList(menuIds);
    }
}
